package homeWork;

import java.util.Scanner;

public class homeWork10 {
    public static void main(String[] args) {
        //递归求 N 的阶乘
        System.out.println("请输入一个整数 N:");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int result = factorial(n);
        System.out.println("N 的阶乘为：" + result);
    }
    public static int factorial(int sum){
        if (sum == 0 || sum == 1){
            return 1;
        }else{
            return sum * factorial(sum - 1);
        }
    }
}
